package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.CrrSupplementRecordreportService;
import com.yunhai.model.entity.crr.CrrSupplementRecordreportEntity;
import com.yunhai.model.vo.crr.CrrSupplementRecordreportQuery;
import com.yunhai.model.vo.crr.CrrSupplementRecordreportVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/crrSupplementRecordreport")
public class CrrSupplementRecordreportController {

	@Resource
	private CrrSupplementRecordreportService crrSupplementRecordreportService;


	/**
	 * 获取 CrrSupplementRecordreport 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getCrrSupplementRecordreportPagination(PaginationVo paginationVo, CrrSupplementRecordreportQuery crrSupplementRecordreportQuery ) throws Exception {
		IPage page = crrSupplementRecordreportService.getCrrSupplementRecordreportPagination(paginationVo, crrSupplementRecordreportQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 CrrSupplementRecordreport 所有数据
	 */
	@GetMapping("/allList")
	public Ret getCrrSupplementRecordreportAllList( CrrSupplementRecordreportQuery crrSupplementRecordreportQuery ) throws Exception {
		List<CrrSupplementRecordreportEntity> list = crrSupplementRecordreportService.getCrrSupplementRecordreportAllList( crrSupplementRecordreportQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 CrrSupplementRecordreport 详情
	 */
	@GetMapping("/{id}")
	public Ret getCrrSupplementRecordreportDetailById(@PathVariable Long id) throws Exception {

	    CrrSupplementRecordreportEntity crrSupplementRecordreportEntity = crrSupplementRecordreportService.getCrrSupplementRecordreportDetail(id);
		return Ret.ok(crrSupplementRecordreportEntity);
	}


	/**
	 * 新增 CrrSupplementRecordreport
	 * */
	@PostMapping("")
	public Ret addCrrSupplementRecordreport(@RequestBody CrrSupplementRecordreportVo crrSupplementRecordreportVo) throws Exception {

		crrSupplementRecordreportService.addCrrSupplementRecordreport(crrSupplementRecordreportVo);
		return Ret.ok();
	}


	/**
	 * 更新 CrrSupplementRecordreport
	 * */
	@PutMapping("")
	public Ret updateCrrSupplementRecordreport(@RequestBody CrrSupplementRecordreportVo crrSupplementRecordreportVo) throws Exception {

		crrSupplementRecordreportService.updateCrrSupplementRecordreport(crrSupplementRecordreportVo);
		return Ret.ok();
	}


	/**
	 * 删除 CrrSupplementRecordreport
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveCrrSupplementRecordreport( @RequestBody List<Long> ids ) throws Exception {

	    crrSupplementRecordreportService.batchRemoveCrrSupplementRecordreport(ids);
		return Ret.ok();
	}
}
